<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/3/10
  Time: 20:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page isELIgnored="false" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <title>修改轮播图</title>
    <style>
        .parent{
            text-align: left;
            padding: 3% 5%;
        }
        /*.swiper_warp{*/
            /*margin: 3% 5%;*/
        /*}*/
        .title_text{
            font-weight: 600;
        }
        .swiper_warp input{
            width: 90%;
            height: 27px;
        }
        .swiper_time{
            display: inline-block;
        }
        .isEnable{

            font-size: 15px;
        }
        .swiper_warp{
            margin-bottom: 10px;
        }
        .swiper_time{
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
   <div class="parent">
       <input style="display: none" id="id" value="${classInfo.id}">
       <div class="swiper_warp">
           <div class="title_text">课程名称</div>
           <div><input type="text" id="className" value="${classInfo.className}"></div>
       </div>

       <div class="swiper_warp" >
           <div class="title_text">封面图片</div>
           <input type="file" value="点击添加" id="imageUrl">
           <img src="${classInfo.classUrl}">
       </div>
       <div class="swiper_warp" >
           <div class="title_text">课程描述</div>
           <textarea id="classDescribe" >${classInfo.classDescribe}</textarea>

       </div>
       <div> <button onclick="addSign()">提交</button></div>
   </div>
<script type="text/javascript" src="${path}/webapp/js/jquery-3.1.1.js"></script>
<script type="text/javascript">
    function addSign() {
        var className=$("#className").val();
        var classDescribe=$("#classDescribe").val();
        var id=$("#id").val();
        var format=new FormData();
        format.append("imageUrl",$("#imageUrl")[0].files[0]);
        format.append("className",className);
        format.append("classDescribe",classDescribe);
        format.append("id",id);
        $.ajax({
            //几个参数需要注意一下
            type: "post",//方法类型
            url: "${path}/sys/classInfo/updateClassInfo",//url
            data:format,
            dataType:"json",
            processData: false, // 告诉jQuery不要去处理发送的数据
            contentType: false, // 告诉jQuery不要去设置Content-Type请求头
            async:false,
            success: function (result) {

                if("2"==result){
                    alert("请上传jpg格式图片");
                }else if("0"==result){
                    alert("修改失败");
                }else if("1"==result){
                    alert("修改成功");
                window.parent.loadHtml('${path}/sys/classInfo/intoClassInfo')
                window.close();
                }else {
                    alert(result);
                }
            },
            error : function(error) {
                alert("服务器忙");
            }
        })

    }
</script>
</body>
</html>
